﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GUI
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void exitMenuItem_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        private String boxText
        {
            get
            {
                return inputTextBox.Text;
            }
            set
            {
                inputTextBox.Text = value;
            }
        }
        private bool numButtonState
        {
            get
            {
                return num0Button.Enabled;
            }
            set
            {
                num0Button.Enabled = value;
                num1Button.Enabled = value;
                num2Button.Enabled = value;
                num3Button.Enabled = value;
                num4Button.Enabled = value;
                num5Button.Enabled = value;
                num6Button.Enabled = value;
                num7Button.Enabled = value;
                num8Button.Enabled = value;
                num9Button.Enabled = value;
                nextButton.Enabled = value;
            }
        }
        #region 数字按钮点击事件

        private void num1Button_Click(object sender, EventArgs e)
        {
            boxText += 1;
        }

        private void num2Button_Click(object sender, EventArgs e)
        {
            boxText += 2;
        }

        private void num3Button_Click(object sender, EventArgs e)
        {
            boxText += 3;
        }

        private void num4Button_Click(object sender, EventArgs e)
        {
            boxText += 4;
        }

        private void num5Button_Click(object sender, EventArgs e)
        {
            boxText += 5;
        }

        private void num6Button_Click(object sender, EventArgs e)
        {
            boxText += 6;
        }

        private void num7Button_Click(object sender, EventArgs e)
        {
            boxText += 7;
        }

        private void num8Button_Click(object sender, EventArgs e)
        {
            boxText += 8;
        }

        private void num9Button_Click(object sender, EventArgs e)
        {
            boxText += 9;
        }

        private void num0Button_Click(object sender, EventArgs e)
        {
            boxText += 0;
        }
        #endregion
        
        private void InTextChanged(object sender, EventArgs e)
        {
            if (boxText.Length > 12)
            {
                boxText = "越界";
                numButtonState = false;
            }
        }

        private void clearButton_Click(object sender, EventArgs e)
        {
            boxText = "0";
            if (!numButtonState)
                numButtonState = true;
        }
    }
}
